#ifndef __SV2_VIDEO_BASE__
#define __SV2_VIDEO_BASE__

#include <string>
#include <vector>
#include <opencv2/opencv.hpp>
#include <fstream>
#include <queue>
#include <stack>
#include <thread>
#include "sms_core.h"
// #define X86_PLATFORM
// #define JETSON_PLATFORM


namespace sv2 {


class VideoStreamerBase {
public:
  VideoStreamerBase();
  ~VideoStreamerBase();

  void setup(cv::Size size, int port=8554, int bitrate=2, std::string url="/live");  // 2M
  void stream(cv::Mat image);
  void release();
  
  cv::Size getSize();
  int getPort();
  std::string getUrl();
  int getBitrate();
  bool isRunning();
protected:
  virtual bool setupImpl();
  virtual bool isOpenedImpl();
  virtual void writeImpl(cv::Mat image);
  virtual void releaseImpl();
  void _run();

  bool _is_running;
  cv::Size _stream_size;
  int _port;
  std::string _url;
  int _bitrate;
  std::thread _tt;
  std::stack<cv::Mat> _image_to_stream;
};

}
#endif
